<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$siteInfo['title']}-{$siteInfo['subtitle']}</title>
  <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <meta name="description" content="{$siteInfo['description']}">
  <meta name="keywords" content="{$siteInfo['keyword']}">
  <meta name="author" content="Teen">
  <link rel="stylesheet" href="https://unpkg.com/element-ui@2.12.0/lib/theme-chalk/index.css">
  <link rel="stylesheet" href="/themes/default/static/css/common.css" />
  <link rel="stylesheet" href="/themes/default/static/css/home.css" />
</head>
<body>
<div id="app">
  {include file="common/header" /}
  <!--轮播图-->
  <template>
    <div class="block">
      <el-carousel height="600px">
        {volist name="carousel" id="vo"}
        <a href="{:url('/p/'.$vo.id)}">
          <el-carousel-item>
            <img class="carousel-img" src="{$vo.cover_image|default='/uploads/default/default_cover.jpg'}" />
          </el-carousel-item>
        </a>
        {/volist}
      </el-carousel>
    </div>
  </template>
  <!--置顶推荐-->
  {notempty name="topArticle"}
  <div class="with1200 tui">
    <h2>置顶推荐</h2>
    <div class="hr-red"></div>
    <ul>
      {volist name="topArticle" id="vo"}
      <li><a href="{:url('/cate/' .$vo.cate_id)}"><div class="cargory">{$vo.cate.cate_name}</div></a><a href="{:url('/p/' .$vo.id)}"><img src="{$vo.cover_image|default='/uploads/default/default_cover.jpg'}" /><div class="title"><h4>{$vo.title}</h4></div></a></li>
      {/volist}
    </ul>
  </div>
  {/notempty}
  <div class="with1200">
    <!--右侧栏目-->
    <div class="right">
      <div class="rightList">
        <h1>天年网络</h1>
       <div class="hr-red"></div>
        <img src="/themes/default/static/images/TnCMS.jpg" width="325px" height="325px"/>
      </div>
      <!--分类目录-->
      <div class="rightList tag">
        <h1>分类目录</h1>
        <div class="hr-red"></div>
        {volist name="tag" id="vo"}
        <a href="{:url('/cate/' .$vo.cate_id)}">{$vo['cate_name']}</a>
        {/volist}
      </div>
      <!--热门文章-->
      <div class="rightList">
        <h1>热门文章</h1>
        <div class="hr-red"></div>
        {volist name="hot_list" id="vo"}
        <div class="list-content">
          <div class="list-img"><img src="{$vo['cover_image']|default='/uploads/default/default_cover.jpg'}"/></div>
          <div class="list-right">
            <a  href="{:url('/p/' .$vo['id'])}" target="_blank" style="font-size: 15px;color:#737383">{$vo.title|htmlspecialchars_decode|strip_tags|mb_substr=0,15,'utf-8'}</a>
            <p style="color: #C0C0C0;margin: 5px;">{$vo.create_time}</p>
          </div>
        </div>
        <div class="hr"></div>
        {/volist}
      </div>
    </div>
    <!--正文文章列表-->
    <div class="list" id="new-list"></div>
    <div class="load" id="load-new">加载更多</div>
  </div>
</div>
{include file="common/footer" /}
</body>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui@2.12.0/lib/index.js"></script>
<script type="text/javascript" src="/themes/default/static/js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript" src="/themes/default/static/js/home.js" ></script>

<!--自定义JS代码-->
{$statistics|raw}
<script>
  new Vue({
    el: '#app'
  })

  var page = 1;
  loadNews(page);
  $("#load-new").click(function () {
    page = page +1;
    loadNews(page)
  })

  function delHtmlTag(str){
    return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
  }

  function loadNews(page) {
    $.ajax({
      type: "POST",
      url: "/post/newList",
      data: {
        page: page
      },
      success: function (e) {
        if (e.data == ""){
          $("#load-new").text("没有更多了")
          $("#load-new").css({"background":"#999","cursor":"default" })
        }
        $.each(e.data, function (index, item) {

          if (item.cover_image == "") {
            item.cover_image = '/uploads/default/default_cover.jpg';
          }
          if (item.content == null || item.content == ""){
            var introduce = "";
          }else {
            var introduce = delHtmlTag(item.content).substr(0, 60)
          }
          $("#new-list").append('  <div class="list-content">' +
                  '          <div class="list-img"><img src="' + item.cover_image + '"/></div>\n' +
                  '          <div class="list-right">' +
                  '            <a  href="' + '/p/' + item.id + '.html" target="_blank">' + item.title + '</a>' +
                  '<p>'+
                  '<i class="el-icon-view"></i>&nbsp;'+item.read_count+'&nbsp;&nbsp;'+
                  '<i class="el-icon-user"></i>&nbsp;'+item.userInfo.username+'&nbsp;&nbsp;'+
                  '<i class="el-icon-collection-tag"></i>&nbsp;'+item.cate.cate_name+'&nbsp;&nbsp;'+
                  '<i class="el-icon-time"></i>&nbsp;'+item.create_time+'&nbsp;'+
                  '</p>'+
                  '            <p style="color: rgba(0,0,0,.6);font-size: 1rem;margin-top: 20px">' + introduce + '</p>' +
                  '          </div>' +
                  '        </div>')
        })
      }
    })
  }
</script>
</html>